//
//  LPPHelpCellController.m
//  Lottery
//
//  Created by 刘盼 on 16/1/22.
//  Copyright © 2016年 lhheh. All rights reserved.
//

#import "LPPHelpCellController.h"

@interface LPPHelpCellController ()<UIWebViewDelegate>

@end

@implementation LPPHelpCellController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor purpleColor];
    
    UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithTitle:@"关闭" style:UIBarButtonItemStylePlain target:self action:@selector(close)];
    
    self.navigationItem.leftBarButtonItem = item;
    //内容加载不出来（从网络上获取）
//    NSURL *url = [NSURL URLWithString:self.model.html];
    
    NSURL *url = [[NSBundle mainBundle]URLForResource:self.model.html withExtension:nil];
    
    NSURLRequest *req = [NSURLRequest requestWithURL:url];
    
    UIWebView *web = (UIWebView *)self.view;
    
    web.delegate = self;
    
    [web loadRequest:req];
   
}

#pragma mark---------<UIWebViewDelegate>-----------

-(void)webViewDidFinishLoad:(UIWebView *)webView{
    
    NSString *code = [NSString stringWithFormat:@"document.location.href = '#%@';",self.model.ids];
    
    [webView stringByEvaluatingJavaScriptFromString:code];
}
-(void)loadView {
    
    [super loadView];
    
    UIWebView *web = [[UIWebView alloc]init];
    
    self.view = web;
}
-(void)close {
    
    [self dismissViewControllerAnimated:YES completion:nil];
}
@end
